local guxing = fk.CreateSkill{
    name = "lingling__guxing",
}
Fk:loadTranslationTable{
    ["lingling__guxing"] = "孤星",
    [":lingling__guxing"] = "游戏开始时，随机将四张【杀】和三张其他伤害牌置于你武将牌上，称为“煞”。回合开始时，你可以获得两张“煞”。出牌阶段限一次，你可以将一张牌当最后一张“煞”使用，若为【杀】，你摸一张牌。",
    ["$lingling__guxing"] = "煞",
    ["#lingling__guxing-invoke"] = "是否发动 孤星，获得两张“煞”",
    ["#lingling__guxing-use"] = "孤星：将一张牌当 %arg 使用",
}
guxing:addEffect(fk.GameStart,{
    anim_type = "drawcard",
    can_trigger = function (self, event, target, player, data)
        return player:hasSkill(guxing.name)
    end,
    on_cost = Util.TrueFunc,
    on_use = function (self, event, target, player, data)
        local room = player.room
        local cards = table.simpleClone(room.draw_pile)
        table.insertTable(cards, room.discard_pile)
        for i = #cards, 1, -1 do
            if not Fk:getCardById(cards[i]).is_damage_card or Fk:getCardById(cards[i]).trueName == "slash" then
                table.remove(cards, i)
            end
        end
        cards = table.random(cards, 3)
        local slashs = {"slash","fire__slash","thunder__slash","ice__slash"}
        for index, trueName in ipairs(slashs) do
            local cs = room:getCardsFromPileByRule(".|.|.|.|"..trueName, 1, "allPiles")
            if #cs > 0 then
                table.insertTable(cards, cs)
            end
        end
        player:addToPile("$lingling__guxing", cards, false, guxing.name)
    end,
})
guxing:addEffect(fk.TurnStart,{
    anim_type = "drawcard",
    can_trigger = function (self, event, target, player, data)
        return player:hasSkill(guxing.name) and player == target and #player:getPile("$lingling__guxing") > 1
    end,
    on_cost = function (self, event, target, player, data)
        if player.room:askToSkillInvoke(player,{
            skill_name = guxing.name,
            prompt = "#lingling__guxing-invoke"
        }) then
            return true
        end
    end,
    on_use = function (self, event, target, player, data)
        local room = player.room
        local cards = room:askToChooseCards(player, {
            target = player,
            min = 2,
            max = 2,
            flag = { card_data = {{ "$lingling__guxing", player:getPile("$lingling__guxing") }} },
            skill_name = guxing.name,
        })
        room:obtainCard(player, cards, false, fk.ReasonJustMove, player.id, guxing.name)
    end,
})
guxing:addEffect("viewas",{
    anim_type = "offensive",
    pattern = ".",
    card_num = 1,
    handly_pile = true,
    card_filter = function(self, player, to_select, selected)
        return #selected == 0
    end,
    prompt = function (self, player, selected_cards, selected)
        local name = Fk:getCardById(player:getPile("$lingling__guxing")[1]).name
        return "#lingling__guxing-use:::"..name
    end,
    view_as = function (self, player, cards)
        if #player:getPile("$lingling__guxing") > 1 or #cards ~= 1 then return end
        local name = Fk:getCardById(player:getPile("$lingling__guxing")[1]).name
        local card = Fk:cloneCard(name)
        card:addSubcards(cards)
        card.skillName = guxing.name
        return card
    end,
    enabled_at_play = function (self, player)
        return player.phase == player.Play and player:usedEffectTimes(self.name,Player.HistoryPhase) == 0 and #player:getPile("$lingling__guxing") == 1
    end,
    enabled_at_response = function (self, player, response)
        return false
    end,
})
guxing:addEffect(fk.CardUseFinished,{
    can_refresh = function(self, event, target, player, data)
        return target == player and table.contains(data.card.skillNames, guxing.name) and data.card.trueName == "slash" and not player.dead
    end,
    on_refresh = function(self, event, target, player, data)
        player:drawCards(1, guxing.name)
    end,
})
return guxing